<extend name="./public/frame.html"/>
<block name="content">
    <form class="layui-form" action="{:url('schedule_edit')}" method="post" enctype="multipart/form-data">
        <table class="layui-table">
            <tr>
                <td>姓名</td>
                <td>
                    <select name="admin_id" class="layui-input" lay-filter="admin_id" lay-verify="required" onchange="sel_custom()">
                        <option value="">--请选择客服人员--</option>
                        <volist name="info" id="vo">
                            <option value="{$vo['admin_id']}" <if condition="$cus_info['admin_id'] eq $vo['admin_id']">selected="selected"</if>>{$vo['user_name']}</option>
                        </volist>
                    </select>
                </td>
            </tr>
            <tr>
                <td>排班路线</td>
                <td>
                    {$cus_info['blong_route_info']}
                </td>
            </tr>
            <tr>
                <td>手机号</td>
                <td>
                    <input name="cus_phone" type="text" class="layui-input" lay-verify="number|phone" maxlength="11" value="{$cus_info['phone']}" placeholder="填写用于接收下单短信的手机号"/>
                </td>
            </tr>
            <tr>
                <td>排班时间</td>
                <td>
                    <div class="layui-inline">
                        <input type="text" class="layui-input date" readonly id="start" name="start_time" placeholder="开始时间" value="{$cus_info['start_time']}" lay-verify="required" style="width: 240px;">
                    </div>
                    <div class="layui-inline">
                        <input type="text" class="layui-input date" readonly id="end" name="end_time" placeholder="结束时间" value="{$cus_info['end_time']}" lay-verify="required" style="width: 240px;">
                    </div>
                </td>
            </tr>
            <tr>
                <td>备注</td>
                <td>
                    <textarea placeholder="请输入内容" class="layui-textarea" name="remark"></textarea>
                </td>
            </tr>

        </table>
        <input type="hidden" name="id" value="{$cus_info['id']}">
        <button class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
        <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
    </form>
    <script>
        layui.use(['form','laydate','table'], function () {
            var table = layui.table, form = layui.form, laydate = layui.laydate;
            lay('.date').each(function () {
                laydate.render({
                    elem: this
                    , type: 'datetime'
                    , trigger: 'click'
                });
            });
            //监听开关
            form.on('switch(switch)', function (data) {
                $(data.elem).prev('input').val(2);
                if (data.elem.checked) {
                    $(data.elem).prev('input').val(1);
                }
            });

//            //监听提交
//            form.on('submit(submit)', function (data) {
//
//            });

            //监听开关
            form.on('select(admin_id)', function (data) {
//                console.log(data.value);
                var sel_admin_id = data.value;
                $.post('get_css_phone',{admin_id : sel_admin_id},function(res){
                    if(res.code === 1) {
                        $("input[name='cus_phone']").val(res.data);
                    } else {
                        $("input[name='cus_phone']").val('');
                    }
                },'json');
            });

        });

//        //同步改变 客服对应的手机号码
//        function sel_custom() {
//            alert(111);
//            var sel_admin_id = $("select[name='admin_id']:selected").val();
//            alert(sel_admin_id);
//        }

    </script>
</block>